// models/VolunteerActivity.js
import { createConnection } from 'mysql';

const connection = createConnection({
  host: 'localhost',
  user: 'root',
  password: '123456',
  database: 'volunteer'
});

connection.connect();

const VolunteerActivity = {
  getAll: (callback) => {
    connection.query('SELECT * FROM volunteer_activities', (err, results) => {
      callback(err, results);
    });
  },
  create: (activity, callback) => {
    connection.query('INSERT INTO volunteer_activities SET ?', activity, (err, result) => {
      callback(err, result);
    });
  },
  update: (id, activity, callback) => {
    connection.query('UPDATE volunteer_activities SET ? WHERE id = ?', [activity, id], (err, result) => {
      callback(err, result);
    });
  },
  remove: (id, callback) => {
    connection.query('DELETE FROM volunteer_activities WHERE id = ?', id, (err, result) => {
      callback(err, result);
    });
  }
};

module.exports = VolunteerActivity;
